<html>
<head>
<title>Exams Overview</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
<link type="text/css" rel="stylesheet" href="/stylesheets/question_search.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" ></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" ></script>
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/dark-hive/jquery-ui.css" />
<script>  

$(function() { // JQuery lookup function
	$( "#exams" ).autocomplete({
		source: "/exam_search_json",
                select: function (event, ui) { $("#exam-id").val(ui.item.id);}
	});
});

function doExamEdit() {
        var examId = "";	
	examId = document.getElementById('exam-id').value;
	if (examId) {
		document.location = "/exam_edit?id="+examId;
	}
}

//    function examDoDelete(theExamId) {
//    	if (confirm("Delete exam: " + theExamId + "?") == 1) {
//	    strExamId = theExamId.toString();
//	    document.location = "/exam_delete?examId=" + strExamId; 
//	}
//    }

</script>
</head>
  <body>
  <h2>Exams Overview</h2>
  <hr>
<!-- Start Exam look-up functionality -->  
<form name="frmFindExam" id="frmFindExam" method="get"></br>
     <div class="ui-widget" id="e" name="e">
	<label for="exams">Find Exam: </label>
	<input  id="exams">
	<input name="examId"  id="exam-id">
	<input name="examId"  type="hidden" value="{{ id }}">
	<input type="Button" onClick="doExamEdit()" value="Edit" name="Edit" id="Edit">
     </div>
</div>
<form>
<!-- Stop Exam look-up functionality -->   
  <hr>
    <table border=0>
    {% for e in exams %}
      <tr><td><h3><a href="/exam_edit?id={{ e.id }}">{{ e.name }}</a></td><td>&nbsp;&nbsp;</td>
	  <!-- td><a href="/exam_delete?examId={{ e.id }}"><img class="modPicQuestion" src="img/trash-can.png""></a></td></tr -->
          <!-- td><a onMouseOver="this.style.cursor='hand';" onClick="examId={{ e.id }}; examDoDelete(examId);"><img class="modPicQuestion" src="img/trash-can.png"" --></a></td></tr>
    {% endfor %}
    </table>
    <br><hr><br>
    <a href="/exam_new">Create New Exam</a>
    <hr>
    Double-click to edit an exam.<br>
    Click on the Trash icon to delete an exam.
    <br><br><a href="/">Start page</a>
  </body>
</html>

